package com.example.Lezedata.ui.fragment.commonfragment;

import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;

import com.example.Lezedata.R;
import com.example.Lezedata.ui.fragment.BaseDiaLogFragment;

public class AlertFragment extends BaseDiaLogFragment {
    TextView content;
    TextView cancel;
    TextView ok;
    TextView Detail;

    public View.OnClickListener cancelListener;
    public View.OnClickListener okListener;
    public String text;
    public String detail;
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.sample_c_g_alert_view, container, false);
    }

    @Override
    public void initView() {
        super.initView();
        content = findViewById(R.id.alert_content);
        cancel = findViewById(R.id.alert_cancel);
        ok = findViewById(R.id.alert_ok);
        Detail = findViewById(R.id.detail);
        content.setText(text);
        Detail.setText(detail);
        cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AlertFragment.super.dismiss();
                if (cancelListener != null){
                    cancelListener.onClick(v);
                }
            }
        });
        ok.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AlertFragment.super.dismiss();
                if (okListener != null){
                    okListener.onClick(v);
                }
            }
        });
    }

    @Override
    public int Gravity() {
        return Gravity.CENTER;
    }
}
